package com.atguigu.lease.common.utils;

import java.util.Random;

/**
 * ClassName: VerifyCodeUtil
 * Package: com.atguigu.lease.common.utils
 * Description:
 * 随机生成验证码
 * @Autor: xvyy
 * @Create: 2024/11/21 - 9:32
 * @Version: v1.0
 */
public class VerifyCodeUtil {
    public static String getVerifyCode(int length) {
        StringBuffer stringBuffer = new StringBuffer();
        Random random = new Random();
        for (int i = 0; i < length; i++) {
            //todo 生成随机数，将随机数添加到字符串缓冲区中，随机数范围为0-9
            stringBuffer.append(random.nextInt(10));
        }
        return stringBuffer.toString();
    }
}
